<script src="__PUBLIC__/js/jquery.ketchup.all.js"></script>
<link href="__PUBLIC__/css/jquery.ketchup.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">

function sub(){
	//if(confirm("确定保存？")){doSth(); }
	doSth();
}
function init(obj,arr){
	obj.html('<option value="">请选择</option>');
	for(var i=0;i<arr.length;i++){  
		var a='<option value="'+arr[i]['id']+'">'+arr[i]['name']+'</option>';
		obj.html(obj.html()+a);	
	}	
	
}
function ajaxcity(data){
	var arr=new Array();
	 arr = eval(data);
	init($("#city"),arr);
}
function ajaxdistrict(data){
	var arr=new Array();
	arr = eval(data);
	init($("#district"),arr);
}
function ajaxstatus(data){
	var arr=new Array();
	arr = eval(data);
	if(res.type==3){
				if ( obj.value == '显示' ) {
					$("#status").val='隐藏';
				}else{ 
					$("#status").val='显示';
				}
			}else{
				alert(res.msg);
			}
	if(arr[0]==1){
		
		$("#status").val="显示";
	}else{
		$("#status").val="隐藏";
	}
}
$(document).ready(function(){
	
	$("#province").bind('change',function(){
		var a = $(this).val();
		$.post("{:U($module_name.'/ajaxarea')}",{id: a} ,ajaxcity );
 	});
	$("#city").bind('change',function(){
		var a = $(this).val();
		$.post("{:U($module_name.'/ajaxarea')}", {id: a}  ,ajaxdistrict);
	});
	//文件上传
	//$('#file1').customFileInput({
	//	button_position : 'right'
	//});
});


function banner_item(n){
		if(n==0){
			document.getElementById("banner_list").setAttribute("style","display"); 
			document.getElementById("banner_add").setAttribute("style","display:none");
			document.getElementById("banner_edit").setAttribute("style","display:none");
		}else if(n==1){
			document.getElementById("banner_list").setAttribute("style","display:none");
			document.getElementById("banner_edit").setAttribute("style","display:none");
			document.getElementById("banner_add").setAttribute("style","display");
		}else{
			document.getElementById("banner_list").setAttribute("style","display:none");
			document.getElementById("banner_add").setAttribute("style","display:none");
			document.getElementById("banner_edit").setAttribute("style","display");
		}
	}
	
	
//更新显示或隐藏
function button_status(obj){
	var val=1;
	if ( obj.value == '显示' ){ val = 1;}
	else{ val = 0;}
	$.ajax({
		url:"{:U('Biz/update_field')}",
		type: "POST",
		data: 'id='+obj.name+ '&status='+val,
		dataType: 'JSON',
		timeout: 800,
		success: function(res){
			if(res.statusCode==200){
				if ( obj.value == '显示' ) {
					obj.value='隐藏';
				}else{ 
					obj.value='显示';
				}
				alert(res.message);
			}else{
				alert(res.message);
			}
		},
		error: function (msg) {
			if ( msg.statusText == 'timeout' )	alert('网络超时');
			else alert('更新失败');
		}
	});
}
//更新排序
function banner_orders(obj){
	$.ajax({
		url:"{:U('Biz/update_field')}",
		type: "POST",
		data: 'id='+obj.name+ '&orders='+obj.value,
		dataType: 'JSON',
		timeout: 800,
		success: function(res){
			if(res.statusCode==200){
				alert(res.message);
			}else{
				alert("更新失败");
			}
		},
		error: function (msg) {
			if ( msg.statusText == 'timeout' )	alert('网络超时');
			else alert('更新失败');
		}
	});
};
//删除幻灯
function del_banner(obj,o){
	$.ajax({
		url:"{:U('Biz/del_focus')}",
		type: "POST",
		data: 'id='+obj,
		dataType: 'JSON',
		timeout: 800,
		success: function(res){
			if(res.statusCode==200){
				$(o).parent().parent().parent().remove();
			}else{
				alert("删除失败");
			}
		},
		error: function (msg) {
			if ( msg.statusText == 'timeout' )	alert('网络超时');
			else alert('删除失败');
		}
	});
};
//更新幻灯
function update_banner(obj){
	$.ajax({
		url:"{:U('Biz/get_banners')}",
		type: "POST",
		data: 'id='+obj,
		dataType: 'JSON',
		timeout: 800,
		success: function(res){
			
				document.getElementById("id").value=res.data['id'];
				document.getElementById("picture").src=res.data['picture'];
				document.getElementById("link_url").value=res.data['link_url'];
				document.getElementById("title").value=res.data['title'];
				document.getElementById("orders").value=res.data['orders'];
				document.getElementById("site_id").value=res.data['site_id'];
				banner_item(2);
		},
		error: function (msg) {
			if ( msg.statusText == 'timeout' )	alert('网络超时');
			else alert('幻灯不存在');
		}
	});
};
</script>
<div class="pageContent">
<div class="tabs" currentIndex="0" eventType="click">
	<div class="tabsHeader">
		<div class="tabsHeaderContent">
			<ul>
				<li><a href="javascript:;"><span>网站信息</span></a></li>
				<li><a href="javascript:;"><span>自提点</span></a></li>
				<li><a href="javascript:;"><span>域名设置</span></a></li>
				<li><a href="javascript:;"><span>幻灯片设置</span></a></li>
			</ul>
		</div>
	</div>
	<div class="tabsContent"><div><!--tabs1-->
<div class="pageFormContent">
	<form method="post" action="{:U($module_name.'/info_done')}" class="pageForm required-validate" onsubmit="return validateCallback(this,dialogAjaxDone);">
	<fieldset>
		<legend>网站信息</legend>
		<dl>
			<dt>店铺名称：</dt>
			<dd><input value="{$site.name}" type="text" name="name" data-validate="validate(required)" ></dd>
		</dl>
		<dl>
			<dt>网站标题：</dt>
			<dd><input value="{$site.title}" type="text" name="title" data-validate="validate(required)" ></dd>
		</dl>
		<dl>
			<dt>网站关键字：</dt>
			<dd><input value="{$site.keyword}" type="text" name="keyword" data-validate="validate(required)" ></dd>
		</dl>
		<dl>
			<dt>网站描述：</dt>
			<dd><input value="{$site.info}" type="text" name="info" data-validate="validate(required)" ></dd>
		</dl>
		<dl>
			<dt>电子邮箱：</dt>
			<dd><input value="{$site.email}" type="text" name="email" data-validate="validate(required,email)" ></dd>
		</dl>
		<dl>
			<dt>QQ在线客服：</dt>
			<dd><input value="{$site.qq}" type="text" name="qq" data-validate="validate(required, digits)"></dd>
		</dl>
		<dl>
			<dt>联系电话：</dt>
			<dd><input value="{$site.telephone}" type="text" name="telephone"></dd>
		</dl>
		<dl>
			<dt>手机号码：</dt>
			<dd><input value="{$site.cellphone}" type="text" name="cellphone" data-validate="validate(required, digits)"></dd>
		</dl>
		<dl>
			<dt>阿里旺旺：</dt>
			<dd><input value="{$site.aliww}" type="text" name="aliww" data-validate="validate(digits)"></dd>
		</dl>
		<dl>
			<dt>LOGO设置：</dt>
			<dd><img src="{$site.logo}" /></dd>
		</dl>
		<dl>
			<dt><input value="{$site.id}" type="hidden" name="id"><input value="1" type="hidden" name="submit"></dt>
			<dd><input value="重置" type="reset" name="reset"><input value="保存" type="submit"></dd>
		</dl>
	</fieldset>
	</form>
</div>
		</div><!--tabs1-->
		<div><!--tabs2-->
<div class="pageFormContent">
<form method="post" action="{:U($module_name.'/info_done')}" class="pageForm required-validate" onsubmit="return validateCallback(this,dialogAjaxDone);">
			<fieldset style="height:335px;">
		<legend>自提点设置</legend>
			<dl>
				<dt>联系人：</dt>
				<dd><input value="{$o2o_store.consignee}" type="text" name="consignee" data-validate="validate(required)"></dd>
			</dl>
			<dl>
				<dt>邮编：</dt>
				<dd><input value="{$o2o_store.zipcode}" type="text" name="zipcode" data-validate="validate(required,digits)"></dd>
			</dl>
			<dl>
				<dt>联系电话：</dt>
				<dd><input value="{$o2o_store.tel}" type="text" name="tel"></dd>
			</dl>
			<dl>
            
            				<dt>自提点地址:</dt>	
							<dd><!-- 省 --><div class="pageContent">
							<select class="sel ml15" name="province" id="province" >
								<option value="">选择省</option>
								<volist name="provinces" id="prov">                                 
									<option value="{$prov.id}" <eq name="prov.id" value="$o2o_store.province"> selected = 'selected' </eq> >{$prov.name}</option>                          
								</volist>
							</select>
							<!-- 市 -->
							<select class="sel" id="city" name="city">
								<option  value="">选择市</option>
								<volist name="city" id="city">                  
									<option value="{$city.id}" <eq name="city.id" value="$o2o_store.city"> selected = "selected" </eq>>{$city.name}</option>                
								</volist>
							</select>
							<!-- 市 -->
							<select class="sel" id="district" name="district">
								<option value="">选择县、区</option>
								<volist name="district" id="district">
									<option value="{$district.id}" <eq name="district.id" value="$o2o_store.district"> selected = "selected" </eq>>{$district.name}</option>
								</volist>
							</select>
                            </div>
                            </dd>
            
			</dl>
			<dl>
				<dt>详细地址：</dt>
				<dd><input value="{$o2o_store.address}" type="text" name="address" data-validate="validate(required)"></dd>
			</dl>
			
		<dl>
			<dt><input value="{$o2o_store.id}" type="hidden" name="id"><input value="{$cid}" type="hidden" name="pid"><input value="2" type="hidden" name="submit"></dt>
			<dd><input value="重置" type="reset"><input value="保存" type="submit"></dd>
		</dl>
        </fieldset>
        </form>
</div>
		</div><!--tabs2-->
		<div><!--tabs3-->
<div class="pageFormContent">
<form method="post" action="{:U($module_name.'/info_done')}" class="pageForm required-validate" onsubmit="return validateCallback(this,dialogAjaxDone);">
			<fieldset style="height:315px;">
		<legend>二级域名设置</legend>
			<dl>
				<dt>二级域名：</dt>
				<dd><input value="{$site.domain}" type="text" name="domain" data-validate="validate(required)"></dd>
			</dl>
			<dl>
				<dt>顶级域名：</dt>
				<dd><input value="{$site.link_url}" type="text" name="link_url" data-validate="validate(required,url)"></dd>
			</dl>
			<dl>
				<dt>ICP备案：</dt>
				<dd><input value="{$site.link_url_icp}" type="text" name="link_url_icp"></dd>
			</dl>
			</fieldset>
		<dl>
			<dt><input value="{$site.id}" type="hidden" name="id"><input value="1" type="hidden" name="submit"></dt>
			<dd><input value="重置" type="reset"><input value="保存" type="submit"></dd>
		</dl>
        </form>
</div></fieldset>
		</div><!--tabs3-->

<div class="pageFormContent"><!--tabs4-->
<fieldset style="height:335px;">
		<div> 
        <div>
        <input type="button" value="幻灯片管理" onclick="banner_item(0)"/><input type="button" value="添加幻灯片" onclick="banner_item(1)"/>
        </div>
            <div id="banner_list" name="banner_list">
            <table class="table" layoutH="110" width="100%">
		<thead>
			<tr>
            <th width="10%" align="center" bgcolor="#ebebeb">排序
                </th><th width="20%" align="center" bgcolor="#ebebeb">广告标题
                </th><th width="30%" align="center" bgcolor="#ebebeb">广告图片
                </th><th width="15%" align="center" bgcolor="#ebebeb">显示状态
                </th><th width="25%" align="center" bgcolor="#ebebeb">操作
                </th>
          	</tr>
 		</thead>
  <tbody>
  <volist name="list" id="banners">
  <tr target="sid_dv">
    <td>
      <input value="{$banners['orders']}" name="{$banners['id']}" type="text" style="width:40px;height:25px;text-align:center;" onblur="banner_orders(this);">
	</td>
    <td>{$banners['title']}</td>
    <td><img src="{$banners['picture']}" onclick="showimgs(this);" pic="{$banners['picture']}" style="margin:10px 0;width:120px;height:50px;"></td>
    <td><input type="button" name="{$banners['id']}" onclick="button_status(this);" value="{if $banners['status']=='1'}隐藏{else}显示{/if}" onfocus="this.select();" ></td>
 	<td><a href="#" onclick="javascript:update_banner({$banners['id']});">编辑</a>/<a href="javascript:;" onclick="del_banner({$banners['id']},this);">删除</a></td>
  </tr>
  </volist>
  </tbody></table>
		</div>
<form method="post" action="{:U($module_name.'/info_done')}" class="pageForm required-validate" enctype="multipart/form-data">
<div style="display:none" id="banner_edit" id="banner_edit">
		<table border="0" cellspacing="0" cellpadding="0">
        	<tr height="40">
				<td width="100">图片 :
				</td>
				<td><img id="picture" name="picture" style="margin:10px 0;width:288px;height:129px;"/><input id="file1" name="banner1" type="file">（图片尺寸：960x430px）</td>
            </tr>
            
			<tr height="40">
            	<td>链接地址 :</td>
				<td><input  id="link_url" name="link_url"  type="text"></td>
            </tr>
            
			<tr height="40">
            	<td>标题 :</td>
				<td><input id="title"  name="title" type="text" value="{$banner.title}"></td>
			</tr>
			<tr height="40">
            	<td>排序 :</td>
				<td><input id="orders"  name="orders" type="text" style="width:40px;" value="{$banner.orders}">（填写数字，如1显示第一张；2显示第二张）</td>
			</tr>	    	
    </table>	

	<div class="form-actions">
    <input  type="hidden" name="id" id="id"><input type="hidden" id="site_id" name="site_id"><input value="3" type="hidden" name="submit">
		<input type="submit" class="btn btn-primary" value="提交" style="width:50px;float:none;"/>&nbsp;&nbsp;&nbsp;
		<input type="reset" class="btn" value="重置" style="width:50px;float:none;"/>
	</div>
</div>
</form>
<form method="post" action="{:U($module_name.'/info_done')}" enctype="multipart/form-data" class="pageForm required-validate" onsubmit="return iframeCallback(this);">
     <div style="display:none" id="banner_add" id="banner_add">
     
	<table border="0" cellspacing="0" cellpadding="0">
	  <tbody><tr height="40">
	    <td width="100">
	    	<label for="UserAddress_consignee">图片</label>
		</td>
	    <td><input  id="file1" name="banner1" class="h20" type="file">（图片尺寸：1210x430px）</td>
	  </tr>
	  <tr height="40">
	    <td>链接地址</td>
	    <td><input name="link_url" type="text" value=""></td>
	  </tr>
	  <!--<tr height="40">
	    <td>链接类型</td>
	    <td><input name="type" type="text" value="{$banner.type}"> *APP使用</td>
	  </tr>
	  <tr height="40">
	    <td>链接对象</td>
	    <td><input name="obj_id" type="text" value="{$banner.obj_id}"> *APP使用</td>
	  </tr>-->
	  <tr height="40">
	    <td>标题</td>
	    <td><input name="title" type="text" value=""></td>
	  </tr>
	  <tr height="40">
	    <td>排序</td>
	    <td><input name="orders" type="text" style="width:40px;" value="">（填写数字，如1显示第一张；2显示第二张）</td>
	  </tr>
	</tbody></table>
    <input value="{$cid}" type="hidden" name="site_id">
    <input value="3" type="hidden" name="submit">
	<input type="submit" class="btn btn-primary" value="提交" style="width:50px;float:none;">&nbsp;&nbsp;&nbsp;
	<input type="reset" class="btn" value="重置" style="width:50px;float:none;">
            </div> 
             </form>
		</div>
	</div><!--tabs4-->
    </fieldset>
    
        </div>
	<div class="tabsFooter">
		<div class="tabsFooterContent"></div>
	</div>
</div>
<style>
.ketchup-error{
	z-index:99;
}
</style>
<script>
$(function(){
	$('form').ketchup();
	$('div.tabsHeaderContent li').live({
		"click":function(){
			$('div.ketchup-error').css({"opacity": 0,"display":"none"});
		}
	});
	$('button').live({
		"click":function(){
			$('div.ketchup-error').css({"opacity": 0,"display":"none"});
		}
	});
});

</script>